package com.tqhh.meimei.exception;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public ModelMap globalException(Exception ex) {
        return resultMapper(ex.toString());
    }


    private ModelMap resultMapper(Object resultValue) {
        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("success", true);
        modelMap.addAttribute("result", resultValue);
        modelMap.addAttribute("message", "OK");
        return modelMap;
    }
}
